Function isotope::parser::natural [−][src]
pub fn natural(input: &str) -> IResult<&str, BigUint>
Expand description
Parse a natural number literal
A natural number literal is either
- A sequence of decimal digits, e.g.
00120013 - A sequence of hexadecimal digits prefixed by
0x, e.g.0xABC - A sequence of octal digits prefixed by
0o, e.g.0o163 - A sequence of binary digits prefixed by
0b, e.g.0b1101
Examples
assert_eq!(natural("0123hello"), Ok(("hello", 123u32.into()))); assert_eq!(natural("0xABCH"), Ok(("H", 0xABCu32.into()))); assert_eq!(natural("0o129"), Ok(("9", 0o12u32.into()))); assert_eq!(natural("0b0111012"), Ok(("2", 0b011101u32.into()))); assert_eq!(natural("0b2"), Ok(("b2", 0u32.into())));